package com.healthy.service;
import com.healthy.entity.Knowledgecontent;
import com.healthy.mapper.KnowledgecontentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KnowledgecontentService {

    @Autowired
    KnowledgecontentMapper knowledgecontentMapper;

    //    查询全部
    public List<Knowledgecontent> cuList() {
        return knowledgecontentMapper.culist();
    }

    //    模糊查询
    public List<Knowledgecontent> cuSelect(String problem) throws Exception {
        return knowledgecontentMapper.cuSelect(problem);
    }

    //    查询全部
    public List<Knowledgecontent> cuInside() {
        return knowledgecontentMapper.cuInside();
    }

    //    查询全部
    public List<Knowledgecontent> cuOutside() {
        return knowledgecontentMapper.cuOutside();
    }

    //    添加
    public Knowledgecontent cuInsert(Knowledgecontent knowledgecontent) {

        knowledgecontentMapper.cuInsert(knowledgecontent);
        return knowledgecontent;
    }

    //    删除
    public int cuDeleteByid(int id) throws Exception {
        int res = knowledgecontentMapper.cuDeleteByid(id);
        if (res > 0) {
            return 1;
        } else {
            return 0;
        }
    }
    //    修改
    public int cuUpdateByid(int id,String type,String problem,String answer,String doctor) throws Exception {
        int res = knowledgecontentMapper.cuUpdateByid(id,type,problem,answer,doctor);
        if (res > 0) {
            return 1;
        } else {
            return 0;
        }
    }
}
